package org.java.dao;

import org.java.util.JdbcUtil;
import org.springframework.jdbc.core.JdbcTemplate;

import java.util.List;

/**
 * Created by IntelliJ IDEA.
 *
 * @Author :王特
 * @create: 2022/03/07 18:50
 */
public class managerUserDao {
 private  JdbcTemplate jdbcTemplate=new JdbcTemplate(JdbcUtil.getDs());

    public Integer login(String username,String password){

        String sql = "select count(*) from administration where uname = ? and upwd=? ";


       Integer count= jdbcTemplate.queryForObject(sql,Integer.class,username,password);
        if (count.equals(1)){
            sql="select state from user  where uname=?and upwd=?";
            count= jdbcTemplate.queryForObject(sql ,Integer.class,username,password);

            if (count.equals(0)){
                return count=2;

            }else {
                return count;

            }

        }else {
            return count;
        }

    }


}